package com.nali.dal.statement.selectupsert;

import java.util.List;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;

import com.nali.dal.dao.general.IGeneralOperateDao;
import com.nali.dal.statement.query.ColumnUnitFactory;
import com.nali.dal.statement.query.SelectStatement;
import com.nali.dal.statement.upsert.OperateUpserter;

/**
 * OperateSelectUpserterStatement<br>&nbsp;
 * @see OperateUpserter
 * @author sam Created on 2011-4-28
 */
public class OperateSelectUpserterStatement extends SelectStatement {
	private OperateUpserter upserter;
	
	public SelectUpserter getSelectUpserter() {
		return new SingleSelectUpserter(getSelecter(), upserter);
	}

	@Autowired
	public OperateSelectUpserterStatement(ColumnUnitFactory columnUnitFactory, IGeneralOperateDao operateDao) {
		upserter=new OperateUpserter();
		upserter.setColumnUnitFactory(columnUnitFactory);
		upserter.setOperateDao(operateDao);
	}

	@PostConstruct
	public void check() {
		upserter.check();
	}

	public void setInto(String table) {
		upserter.setTable(table);
	}
	
	public void setIdentitfiedBy(List<String> identitfiedBy) {
		upserter.setIdentitfiedBy(identitfiedBy);
	}
	
	public void setMatch(List<String> conds) {
		upserter.setWhere(conds);
	}
	
	public void setModify(List<String> ops) {
		upserter.setModify(ops);
	}

	public void setModifyAll(boolean all) {
		upserter.setModifyAll(all);
	}

	public void setUpsert(boolean upsert) {
		upserter.setUpsert(upsert);
	}
}